package com.zhoust.controller;

import com.zhoust.service.UserService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author 15703
 * @version 1.0
 * @Title
 * @package com.zhoust.controller
 * @date 2020/9/16 22:59
 * @desc
 */
@RestController()
public class HelloTestController {

    final static Logger logger = LoggerFactory.getLogger(HelloTestController.class);

    @GetMapping("/getHello")
    public String getHello(){
        return "hello test";
    }
    @Autowired
    private UserService userService;
    @GetMapping("/isEx")
    public String isEx(){
        boolean zho = userService.queryUsernameIsExist("zho");
        return "hello test" +zho;
    }
    @GetMapping("/setSession")
    public Object setSession(HttpServletRequest request) {
        HttpSession session = request.getSession();
        session.setAttribute("userInfo", "new user");
        session.setMaxInactiveInterval(3600);
        session.getAttribute("userInfo");
//        session.removeAttribute("userInfo");
        return "ok";
    }

}
